local skel = fk.CreateSkill{
  name = "lb__fenxiao_zhuhuo",
  tags = {Skill.Limited},
}

skel.visible = true

Fk:loadTranslationTable{
  ["lb__fenxiao_zhuhuo"] = "逐火",
  --[":lb__fenxiao_zhuhuo"] = "<b>限定技</b>，当你濒死时，你可以将体力值回复至已阵亡角色数，弃置所有手牌，然后获得弃牌堆中所有的属性【杀】，若数量为十二，你方阵营胜利。",
  --8.30
  --[":lb__fenxiao_zhuhuo"] = "<b>限定技</b>，当你濒死时，你可以将体力值回复至已阵亡角色数，弃置所有手牌，然后获得弃牌堆中所有的属性【杀】。",
  --9.2
  [":lb__fenxiao_zhuhuo"] = "<b>限定技</b>，当你濒死时，你可以将体力值回复至已阵亡角色数，弃置所有手牌，然后获得弃牌堆中所有的属性【杀】，并于此回合结束后获得一个出牌阶段。 ",

  ["#lb__fenxiao_zhuhuo"] = "逐火：你可以将体力值回复至%arg，弃置所有手牌，然后获得弃牌堆中所有的属性【杀】，于此回合结束后获得一个出牌阶段",--，若数量为十二，你方阵营胜利。",

  ["$lb__fenxiao_zhuhuo1"] = "亿万火种之怒，燃尽此身！",
  ["$lb__fenxiao_zhuhuo2"] = "赐你，众星俱焚的曙光！",
}

skel:addEffect(fk.EnterDying, {
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(skel.name) and target == player and player:usedSkillTimes(skel.name, Player.HistoryGame) == 0 and
    table.find(player.room.players,function (t)
      return t.dead
    end)
  end,
  on_cost = function (self, event, target, player, data)
    local room = player.room
    local n = #table.filter(player.room.players,function (t)
      return t.dead
    end)
    return room:askToSkillInvoke(player, {skill_name = skel.name, prompt = "#lb__fenxiao_zhuhuo:::"..n})
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local n = #table.filter(player.room.players,function (t)
      return t.dead
    end)
    room:recover{
      who = player,
      num = n - player.hp,
      skillName = skel.name,
      recoverBy = player,
    }
    player:throwAllCards("h")
    local cards = table.filter(room.discard_pile,function (id)
      local card = Fk:getCardById(id)
      --return card.trueName == "slash" and card.name ~= "slash"  --需要考虑还有刺杀之类的
      return table.contains({"fire__slash","thunder__slash","ice__slash"},card.name)
    end)
    if #cards > 0 then
      room:obtainCard(player,cards,true,fk.ReasonJustMove,player,skel.name)
      --[[
      if #cards == 12 then
        if player.role == "lord" or player.role == "loyalist" then
          player.room:gameOver("lord+loyalist")
        else
          player.room:gameOver(player.role)
        end
      end
      --]]
      player:gainAnExtraPhase(Player.Play, skel.name) -- 9.2
    end
  end,
})

skel:addEffect(fk.EventAcquireSkill, {
  can_refresh = function(self, event, target, player, data)
    return player:hasSkill(skel.name,true,true) and data.skill:getSkeleton() and data.skill:getSkeleton().name == "lb__zhuhuo"
  end,
  on_refresh = function(self, event, target, player, data)
    player.room:handleAddLoseSkills(player, "-lb__zhuhuo", nil, false, true)
  end,
})

return skel